package com.iwhalecloud.citybrain.flow.platform.manager.application.common.command;

import org.flowable.engine.common.impl.interceptor.Command;
import org.flowable.engine.common.impl.interceptor.CommandContext;
import org.flowable.engine.impl.util.CommandContextUtil;
import org.flowable.form.engine.FormEngineConfiguration;
import org.flowable.form.engine.impl.persistence.entity.FormResourceEntity;

import java.io.Serializable;

/**
 * @author cheng.huaxing
 * @date 2019-02-28
 */
public class FormResourcePersistCmd implements Command<Void>, Serializable {

    private FormResourceEntity formResourceEntity;


    public FormResourcePersistCmd(FormResourceEntity formResourceEntity) {
        this.formResourceEntity = formResourceEntity;
    }

    @Override
    public Void execute(CommandContext commandContext) {
        ((FormEngineConfiguration) CommandContextUtil.getFormEngineConfiguration(commandContext))
                .getResourceEntityManager()
                .insert(formResourceEntity);
        return null;
    }
}
